{extend name="public/common"}
{block name="style"}
<title>点对点教育VIP学员_学员管理</title>
<link rel="stylesheet" href="__HOME__/css/mui/mui.min.css">
<link rel="stylesheet" href="__HOME__/css/user/leader.css">
<style>
    .default {
        width: 100%;
        height: 100%;
        position:absolute;
    }
    .default img {
        width: 19vw;
        height: 29vw;
        margin-top: 22vh;
        margin-left: 41vw;
    }
    .mui-pull-bottom-pocket{
     height: 10vw!important;
    }
    .mui-pull-caption{
     font-size: 1.3rem;
    }

    .mui-popover .mui-table-view{
        text-align: center;
    }
    #popover {
        height: 300px;
    }
    .bott{
        width:100%;
        text-align: center;
        height:4vw;
        position: relative;
        z-index:9999;
        display: none;
        margin-top:50vw;
        font-size:1.6rem;
    }
    .play{
        color: #1eca4f;
        height:10vw;
        line-height: 12vw;
        font-size: 1.5rem;
        float: left;
        margin-left: 2vw;
    }
    .plays{
        color: #1eca4f;
        height:10vw;
        line-height: 12vw;
        font-size: 1.5rem;
        margin-left: 70vw;
    }
    .list ul a .scan{
        color: red;
        margin-left: 2vw;
        width: 0;
    }
    .list {
        margin-top: 23vw;
    }
    .search{
        background: #f0eff5;
        padding:2.133vw 1vw;
        border-bottom: 1px solid #f0eff5;
        position: relative;
        z-index:5;
    }
    .search>.searchBox{
        border-radius: 5px;
        height:7.466vw;
        background: #ffffff;
        width: 45%;
        padding-left: 2vw;
        float: left;

    }
    .search>.searchBox>.searchInput{
        display: none;
    }
    .search>.searchBox>.searchText{
        display: inline-block;
        font-size:1.4rem;
        color: #999;
        padding-left:6.4vw;
        min-width: 1px;
        line-height: 7.46vw;
        height:7.46vw;
        background: url("/DDDeducation/public/home/images/user/search.png") 0 50% no-repeat;
        background-size: 4.8vw 4.8vw;
    }
    #openPopover2{
        display: inline-block;
        width: 48%;
        border-radius: 5px;
        margin-left: 5vw;
        padding:0.9vw 1vw;
        color: #8f8f94;
        font-size: 1.5rem;
        background: #ffffff;
        text-align: center;
    }
    #openPopover2:after{
        display: inline-block;
        content: '';
        width: 0;
        height: 0;
        border-left: 0.4rem solid transparent;
        border-right: 0.4rem solid transparent;
        border-top: 0.6rem solid #949494;
        margin-left: 0.3rem;
        position: relative;
        top:0.7rem;
        float:right;
    }
    #popover2 {
        height: 300px;
    }
</style>
{/block}
{block name="body"}
<div class="search ">
    <div class="searchBox">
        <div class="searchText"><span class="searchText_c">搜索</span></div>
        <input type="text" class="searchInput">
    </div>
    <div>
        <a id="openPopover2" href="#popover2" data-id=""></a>
    </div>
</div>
<div class="personal-intro">
    <a id="openPopover" href="#popover" data-id=""><p></p></a>
</div>
<div class="line"></div>
<p class="bott">&nbsp;加载中...</p>
<div id="refreshContainer" class="mui-content mui-scroll-wrapper">
    <div class="mui-scroll">
        <div class="mui-slider-group">
<div class="list">
    <div class="play" data-id="">
        详细统计 >>>
    </div>
    <div class="plays" data-id="">
        详细排名 >>>
    </div>
    <ul>

    </ul>
</div>
        </div>
        </div>
    </div>
<div id="popover" class="mui-popover" >
    <div class="mui-scroll-wrapper">
        <div class="mui-scroll">
            <ul class="mui-table-view">
                {volist name="deps" id="de"}
           <li class="mui-table-view-cell" data-id="{$de.id}" data-tab="{$i}"><a>{$de.name}</a></li>
                {/volist}
            </ul>
        </div>
    </div>
</div>
<div id="popover2" class="mui-popover" >
    <div class="mui-scroll-wrapper">
        <div class="mui-scroll">
            <ul class="mui-table-view">
                {volist name="arr" id="a"}
                <li class="mui-table-view-cell" data-id="{$a}"><a>{$a}</a></li>
                {/volist}
            </ul>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script src="__HOME__/js/reset.js"></script>
<script src="__HOME__/js/mui.min.js"></script>
<script>
    $('title').text('点对点教育VIP学员_学员管理');
    mui('.mui-scroll-wrapper').scroll();
    var d = "{$id}";
    var c = "{$d_name}";
    var year = "{$now}";
    if (localStorage.getItem("d") !="" && localStorage.getItem("d") !=null){
         c =localStorage.getItem("c");
         d = localStorage.getItem("d");
    }
    if (localStorage.getItem("year") !="" && localStorage.getItem("year") !=null){
        year = localStorage.getItem("year");
    }
    $("#openPopover p").html(c);
    $("#openPopover").attr('data-id',d);
    $("#openPopover2").html(year);
    $("#openPopover2").attr('data-id',year);
    $(".play").attr('data-id',d);
    $(".plays").attr('data-id',d);
    $(".list ul li").each(function(){
        $(this).remove();
    });
    $.ajax({
        type:"post",
        url:"{:Url('User/select')}",
        data:{
            id:d,
            year:year
        },
        beforeSend: function(XMLHttpRequest){
            $(".bott").show();
        },
        success:function(data){
            if(data.code == 1){
                $(".bott").hide();
                addMeets(data);
                if($(".list ul li").length<20){
                    mui('#refreshContainer').pullRefresh().disablePullupToRefresh();
                }else{
                    mui('#refreshContainer').pullRefresh().enablePullupToRefresh();
                }
            }else{
                $(".bott").hide();
                $(".list ul" ).append('<div class="default"><img src="__HOME__/images/common/nomessage.png" alt="暂无消息"> </div>');
            }
        }
    });

    $("#popover ul li").click(function(){
        var select_it = $(this).text();
        var id = $(this).data("id");
        $("#openPopover p").html(select_it);
        $("#openPopover").attr("data-id",id);
        localStorage.setItem("c","");
        localStorage.setItem("d","");
        var year = $("#openPopover2").attr('data-id');
        $(".list ul li").each(function(){
            $(this).remove();
        });
        $(".default").remove();
        $.ajax({
            type:"post",
            url:"{:Url('User/select')}",
            data:{
                id:id,
                year:year
            },
            beforeSend: function(XMLHttpRequest){
                $(".bott").show();
                mui('#refreshContainer').pullRefresh().disablePullupToRefresh();
            },
            success:function(data){
                var id =$(".personal-intro #openPopover").attr("data-id")
                localStorage.setItem("c",select_it)
                localStorage.setItem("d",id)
                $(".play").attr('data-id',id);
                if(data.code == 1){
                    $(".bott").hide();
                    mui('#refreshContainer').pullRefresh().refresh(true);
                    mui('#refreshContainer').scroll().scrollTo(0,0);
                    mui('#refreshContainer').pullRefresh().refresh(true);
                    addMeets(data);
                    if($(".list ul li").length<20){
                        mui('#refreshContainer').pullRefresh().disablePullupToRefresh();
                    }else{
                        mui('#refreshContainer').pullRefresh().enablePullupToRefresh();
                    }
                }else{
                    $(".bott").hide();
                    $(".list ul" ).append('<div class="default"><img src="__HOME__/images/common/nomessage.png" alt="暂无消息"> </div>');
                }

            }
        })
        mui('#popover').popover("hide");
    });
    $("#popover2 ul li").click(function(){
        var year = $(this).data("id");
        $("#openPopover2").html(year);
        $("#openPopover2").attr("data-id",year);
        var id = $("#openPopover").attr("data-id");
        $(".list ul li").each(function(){
            $(this).remove();
        });
        $(".default").remove();
        $.ajax({
            type:"post",
            url:"{:Url('User/select')}",
            data:{
                id:id,
                year:year
            },
            beforeSend: function(XMLHttpRequest){
                $(".bott").show();
                mui('#refreshContainer').pullRefresh().disablePullupToRefresh();
            },
            success:function(data){
                localStorage.setItem("year",year)
                $(".play").attr('data-id',id);
                if(data.code == 1){
                    $(".bott").hide();
                    mui('#refreshContainer').pullRefresh().refresh(true);
                    mui('#refreshContainer').scroll().scrollTo(0,0);
                    mui('#refreshContainer').pullRefresh().refresh(true);
                    addMeets(data);
                    if($(".list ul li").length<20){
                        mui('#refreshContainer').pullRefresh().disablePullupToRefresh();
                    }else{
                        mui('#refreshContainer').pullRefresh().enablePullupToRefresh();
                    }
                }else{
                    $(".bott").hide();
                    $(".list ul" ).append('<div class="default"><img src="__HOME__/images/common/nomessage.png" alt="暂无消息"> </div>');
                }

            }
        })
        mui('#popover2').popover("hide");
    });
    //初始化下拉加载
    mui.init({
        pullRefresh: {
            container: '#refreshContainer',
            up: {
                callback: loadScroll
            }
        }
    });
    function loadScroll(){
        var len = $(".list ul li").length;
        var id =$(".personal-intro #openPopover").attr("data-id");
        var year = $("#openPopover2").attr("data-id");
        $.ajax({
            type:"post",
            url:"{:Url('User/more')}",
            data:{
                length:len,
                id:id,
                year:year
            },
            beforeSend: function(XMLHttpRequest){

            },
            success:function(data){
                if(data.code == 1){
                    addMeets(data);
                    if(data.data.length == 20){
                        mui('#refreshContainer').pullRefresh().endPullupToRefresh(false);
                    }else{
                        mui('#refreshContainer').pullRefresh().endPullupToRefresh(true);
                    }
                }else{
                    mui('#refreshContainer').pullRefresh().endPullupToRefresh(true);
                }
            }
        })
    }
    function addMeets(data){
        var html = '';
        var lists = data.data;
        var len = lists.length;
        var percent='';
        var percents = '';
        if (lists){
            for(var i = 0; i< len;i++){
                var list = lists[i];
                if(list.percent==0){
                    percent = 0
                }else{
                    percent = (list.percent*100).toFixed(1)+'%'
                }
                if(list.percents==0){
                    percents = 0
                }else{
                    percents = (list.percents*100).toFixed(1)+'%'
                }
                if(list.name){
                    list.str = list.name;
                }else{
                    list.str = list.order_id;
                }
                html+='<li>' +
                        '<div class="head">' +
                        '<img src="'+list.headimgurl+'">' +
                        '<span class="name">'+list.str+'</span>' +
                        '<span class="order">'+list.order_id+'</span></div>' +
                        '<div class="head">' +
                        '<a class="alllog" href="/DDDeducation/public/index.php/home/Journal/personal/openid/'+list.openid+'">总结</a>' +
                        '<a class="alllogs" href="/DDDeducation/public/index.php/home/Test/testlist/openid/'+list.openid+'">测试</a>' +
                        '<a class="alllogss" href="/DDDeducation/public/index.php/home/User/sign/openid/'+list.openid+'">签到</a>'+
                    '<a class="alllogsss" href="/DDDeducation/public/index.php/home/Homework/index/openid/'+list.openid+'">作业</a>'+
                        '<a class="alllogssss" href="/DDDeducation/public/index.php/home/Translate/personal/openid/'+list.openid+'">翻译</a>'+
                        '</div>' +
                        '<div style="color: #999;font-size: 1.4rem;padding: 10vw 0 6vw 2vw;">' +
                        '<span style="float: left;margin-top: -1.5vw;">【签到】';
                        if(list.is_sign == 1){
                            html+='<span style="color: green">√</span>';
                        }else{
                            html+='<span style="color: red">×</span>';
                        }
                        html+='【总结】';
                        if(list.is_summary == 1){
                            html+='<span style="color: green">√</span>';
                        }else{
                            html+='<span style="color: red">×</span>';
                        }
                        html+='【测试】';
                        if(list.is_test == 1){
                            html+='<span style="color: green">√</span>';
                        }else{
                            html+='<span style="color: red">×</span>';
                        }
                        html+='【作业】';
                        if(list.is_homework == 1){
                            html+='<span style="color: green">√</span>';
                        }else{
                            html+='<span style="color: red">×</span>';
                        }
                        html+='【翻译】';
                        if(list.is_translate == 1){
                            html+='<span style="color: green">√</span>';
                        }else{
                            html+='<span style="color: red">×</span>';
                        }
                                html+='</span>' +
                        '</div>' +
                        '</li>';
            }
            $(".list ul" ).append(html);
        }else{
            $(".list ul" ).append('<div class="default"><img src="__HOME__/images/common/nomessage.png" alt="暂无消息"> </div>');
        }
    }
    mui('#refreshContainer').on('tap', '.play', function() {
        var id =$(".play").attr('data-id');
        var url ='http://mp.csppat.com/DDDeducation/public/index.php/home/user/detail/id/'+id;
        window.location.href=url;
    });
    mui('#refreshContainer').on('tap', '.plays', function() {
        var id =$(".play").attr('data-id');
        var url ='http://mp.csppat.com/DDDeducation/public/index.php/home/ranks/index/id/'+id;
        window.location.href=url;
    });
    mui('#refreshContainer').on('tap', 'a', function() {
        var id = this.getAttribute('href');
        window.location.href=id;
    });
    $(".searchBox").on("click",function(){
        var id =$(".play").attr('data-id');
        var url ='http://mp.csppat.com/DDDeducation/public/index.php/home/user/search/id/'+id;
        window.location.href=url;
    });
    //关闭分享
    function onBridgeReady() {
        WeixinJSBridge.call('hideOptionMenu');
    }
    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    } else {
        onBridgeReady();
    }
</script>

{/block}